TCalenPnl, a freeware Calendar descended from TCustomPanel. =========================================================== INSTALLATION. To install TCalenPnl as a component on your button bar, copy the CALPNL.PAS and CALPNL.DCR files to your \LIB folder, then click on Component\Install. Click on the Add button when the 'Install Components' dialogue box shows. Click on the 'Browse' button, navigate to the LIB folder, select CALPNL.PAS, then click on the 'Open' button. You're now back at the 'Install Components' dialogue box, click on 'OK', sit back and twiddle your thumbs for a minute, then the TCalenPnl component will be available in the Samples page of the Component Pallette. If you wish to install TCalenPnl to another page (eg 'Untested components'), go to line 231 of the CALNPNL.PAS file, and change RegisterComponents('Samples', [TCalenPnl]); to... RegisterComponents('Untested components', [TCalenPnl]); =============================== DESCRIPTION, a copy of which is in the CALPNL.PAS file, and could be deleted from there, if you wish... Posted in the hope that I can repay a little of my enormous debt to those many unselfish people who have made my life easier with freeware and code snippets. -o0o- TCalenPnl, a freeware Calendar descended from TCustomPanel. The really hard work for this component was done by Robert Vivrette, and is adapted from his freeware TDateEdit form. I needed a panel-based Calendar, and adapted the CalPop code to suit. TCalenPnl retains all the properties of a TPanel, and adds a few more. Some of the interesting published properties are... ShowDate: Shows\Hides the buttons and 'MMMMM YYYY' display above the abbreviated day names at the top. The Months or Years can then be changed programmatically by ScrollBars or similar. DayWidth: Uses 1 to 3 characters (M, Mo, Mon) to define the day name. Font: Big deal! Actually, the point is that the Font can be changed (typically the size would be changed) when TCalenPnl is Resized (OnResize). OnDateChange: A centralized event that allows users to change Labels, ScrollBars, Graphs or ProgressBars when the CalendarDate property is changed, internally or externally. Some interesting Public properties... CalendarDate: A TDateTime property that you can read or write to programmatically. The fractional part of CalendarDate, i.e. the time, is not stored. WeekNumber: An integer representing the... Week number of the .Year. DayOfYear: Integer value for days that have passed, in the current (CalendarDate) year. DaysInYear: Integer, can be either 365 or 366. It could have just as easily been Boolean (it calls the Boolean IsLeapYear protected Function), but it suited my project. .Day, .Month, .Year are all integer Public Properties. There is some repitition in the code, as Robert's CalPop relies on the date being changed only by the buttons, therefore only in increments of one. I required TCalenPnl to be able to be set by other controls, so there is some duplication. A really clever programmer, over a rainy weekend, could re-do the code to shrink it a touch. You may have to look closely at some of the code, as it has been written to prevent a user entering an invalid date, which can happen with a ScrollBar. If the date highlighted is 31 August, and the user scrolls to September, the CalendarDate.Day is reset to the DaysInMonth (ie, 30), to prevent an error. Shouldn't be a problem as it almost guarantees no errors, but be aware. If you use 'MMMM DD YYYY' format in your Win International settings, ie US users, then the example above would use August 31. In other words, the code is 'Internationalized', to that extent. While CalPnl.PAS and the CalPnl.DCR have been produced in Delphi 2.0, there is no reason why the .PAS would not work in 16 bit Delphi, apart from a few // comments. I considered a dynamic StartOfWeek, as some other calendar programmes offer, because it is culturally presumptuous of me to use Sunday as day 1. If you wish to modify the source, please do so, and send me a copy to re-post. -o0o- If you have any criticisms or suggestions, please send them to me... Peter Crain Brisbane, Queensland. AUSTRALIA. Compuserve 100237,2735